local jianxi = fk.CreateSkill{
    name = "ym2__jianxi",
}
Fk:loadTranslationTable{
    ["ym2__jianxi"] = "兼习",
    [":ym2__jianxi"] = "当你受到伤害时，你摸一张牌并展示之，然后你需声明一个描述中含有此牌牌名且不在场上的技能并获得之，否则你使用基本牌的数值+1。",
    ["@ym2__jianxi_basic"] = "兼习",
    [":ym2__jianxi_basic"] = "使用基本牌的数值增加",
    ["#ym2__jianxi"] = "兼习：获得一个描述中含%arg的技能",
}
local function getSkillNameListall(playerx)--能获取衍生技
    local ret = {}
    if playerx then
        local other_skills = table.map(playerx.other_skills, Util.Name2SkillMapper)
        local self_skills = table.connect(playerx.skills, other_skills)
        local myrelated_skills = table.connect(playerx.related_skills, self_skills)
        local otherskllmap = table.map(playerx.related_other_skills, Util.Name2SkillMapper)
        local skills = table.connect(otherskllmap,myrelated_skills)
        for _, skill in ipairs(skills) do
            table.insert(ret, skill.name)
        end
    end
    return ret
end
local function getOncePerPlaySkillandg(player, string)
    local pool1, pool2 = {}, {}
    local blacklist = {"ofl_other2","tyj_heg","moepack_passer","moepack_moesp","moepack_moesp2","jiange_generals"}
    local extensionblacklist = {"moepack","hegemony","MahjongSoul","hegemony_diy","luming","new_heg","new_heg_diy"}
    local skillblacklist = {}
    local generalblacklist = {"mouxusheng","emotest"}
    for _, general in pairs(Fk:getAllGenerals()) do
        if not table.contains(generalblacklist,general.name) and not general.hidden and not general.total_hidden and not table.contains(extensionblacklist,general.package.extensionName) and not table.contains(blacklist,general.package.name) then
            for _, skn in ipairs(getSkillNameListall(general)) do
                if not player:hasSkill(skn) and not table.contains(skillblacklist,skn) and string.find(Fk:translate(":"..skn, "zh_CN"),string) then
                    table.insert(pool1,general.name)
                    table.insert(pool2,skn)
                end
            end
        end
    end
    return {pool1, pool2}
end
jianxi:addEffect(fk.DetermineDamageInflicted,{
    anim_type = "masochism",
    can_trigger = function (self, event, target, player, data)
        return player:hasSkill(jianxi.name) and player == target
    end,
    on_cost = Util.TrueFunc,
    on_use = function (self, event, target, player, data)
        local room = player.room
        local cards = player:drawCards(1,jianxi.name)
        player:showCards(cards)
        local name = Fk:getCardById(cards[1]).trueName
        if Fk:translate(name,"zh_CN") == name then
            name = Fk:getCardById(cards[1]).name
        end
        local pool = getOncePerPlaySkillandg(player, "【"..Fk:translate(name,"zh_CN").."】")
        --table.sort(pool)
        local result = room:askToCustomDialog(player,{
            skill_name = jianxi.name,
            extra_data = {
                pool[2],
                1,
                1,
                "#ym2__jianxi:::".."【"..Fk:translate(name,"zh_CN").."】",
                pool[1]
            },
            qml_path = "packages/ym_Al/qml/ChooseSkillBoxWithSearch.qml",
        })
        if not result or result == "" then
            room:addPlayerMark(player,"@ym2__jianxi_basic")
        else
            result = json.decode(result)
            room:handleAddLoseSkills(player,table.concat(result,"|"))
        end
    end,
})
jianxi:addEffect(fk.CardUsing, {
    can_refresh = function(self, event, target, player, data)
        return target == player and player:getMark("@ym2__jianxi_basic") > 0 and data.card.type == Card.TypeBasic
    end,
    on_refresh = function(self, event, target, player, data)
        local num = player:getMark("@ym2__jianxi_basic")
        if data.card.is_damage_card then
            data.additionalDamage = (data.additionalDamage or 0) + num
        elseif data.card.name == "peach" then
            data.additionalRecover = (data.additionalRecover or 0) + num
        elseif data.card.name == "analeptic" then
            if data.extra_data and data.extra_data.analepticRecover then
                data.additionalRecover = (data.additionalRecover or 0) + num
            else
                data.extra_data = data.extra_data or {}
                data.extra_data.additionalDrank = (data.extra_data.additionalDrank or 0) + num
            end
        end
    end,
})
return jianxi